
<?php 
header("Content-Type:text/html;charset=utf-8");
include "../inc/page.class.php";
include_once '../inc/conn.php';
require '../inc/checkdate.php';
date_default_timezone_set('PRC');

?>
<html>
<head>

<title>userinfo</title>


<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.tabfont01 {	
	font-family: "宋体";
	font-size: 9px;
	color: #555555;
	text-decoration: none;
	text-align: center;
}
.font051 {font-family: "宋体";
	font-size: 12px;
	color: #333333;
	text-decoration: none;
	line-height: 20px;
}
.font201 {font-family: "宋体";
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.button {
	font-family: "宋体";
	font-size: 14px;
	height: 37px;
}
html { overflow-x: auto; overflow-y: auto; border:0;} 
-->
</style>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">

</script>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<SCRIPT language=JavaScript >

function selectAll(){
	var delid = document.getElementsByName('delid[]');
	for(var i=0;i<delid.length;i++){
		delid[i].checked = true;
		//obj.delid[i].value;
	}

}

function del_message(){
	
	var obj2=document.getElementsByName("delid[]");

	for(var i=0;i<obj2.length;i++){
		if(obj2[i].checked==true){
		temp=1;
		break;
		}else{
		temp=0;
		}
	}
	if(temp==0){alert("请选择!");return false;}
	else{
		
		var msg = "您真的确定要删除吗？请确认！";  
	    if (confirm(msg)==true){ 
	    	var str = "";
			var  delid = document.getElementsByName('delid[]');
			for(var i=0;i<delid.length;i++){
				if(delid[i].checked == true){
					//arr[i]=obj.delid[i].value;
					str +=delid[i].value+"|";
				}
			}
			//window.Location='delete_uid.php?id='+str;
		    window.location.href="delete_message.php?id="+str; 
	        return true;  
	    }else{  
	        return false;  
	    }  
	  
	}
}
function unselectAll(){
	var delid = document.getElementsByName('delid[]');
	for (var i=0;i<delid.length;i++){
		
			if (delid[i].checked==true) delid[i].checked = false;
			else delid[i].checked = true;
		
	}
}

function link(){
    document.getElementById("fom").action="sendxiaoxi.php";
   document.getElementById("fom").submit();
}



</script>
<script language="JavaScript" src ="../js/select_date.js" type="text/javascript">
</script>
</head>

<body>
<form name="fom1" id="fom1" method="post" action="">

<img src="../images/ico07.gif" width="20" height="18" />　
		 
<td width="538">查看内容：按时间：
<input name="start_time" type="text" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()"  />
<span class="newfont06">至</span>
<input name="stop_time" type="text" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()"  />
<input name="search" type="submit" class="right-button02" value="查 询" /></td>
				
				
</form>

<br>
<?php 
/* 定义一个显示用户信息的方法 */
$query_str="select * from message";
$result_all=$oa->query($query_str);
$total=mysql_num_rows($result_all);
$num=10;

$page=new Page($total, $num, "&id");
$dis_page='<table><tr><td align="left" width="600">'.$page->fpage(array(0,2)).'</td><td align="right" width="500">'.$page->fpage(array(4,5,6,7,8))."</td></tr></table>";
function list_task($result,$dis_page){
	$nums=mysql_num_rows($result);
	if($nums==0)
	{
		echo "<font color=red>没有找到相关记录!</font>";
	}
	else{
			echo '<form name="fom"  id="fom" >';
			echo  '<td><table id="subtree1" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0">';
			echo   '    <tr>';
			echo'          <td><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">';
			echo'       <tr>
			               <td height="20"><span class="newfont07">选择：<a href="#" class="right-font08" onclick="selectAll();">全选</a>-<a href="#" class="right-font08" onclick="unselectAll();">反选</a></span>
	              <input name="Submit" type="button" class="right-button08" value="删除所选消息" onclick="del_message()"/>
	              <input name="Submit2" type="button" class="right-button08" onclick="link();" value="发送消息"/></td>
       	    </tr>
              <tr>
                <td height="40" class="font42">
				<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#464646" class="newfont03">
				 <tr class="CTitle" >
                    	<td height="22" colspan="8" align="center"  bgcolor="#EEEEEE"class="tablestyle_title">消息列表</td>
                  </tr>
                  <tr bgcolor="#EEEEEE">
				    <td width="6%" align="center" height="30">选择</td>
                    <td width="12%">标题</td>
					<td width="12%">接受人</td>
                    <td width="12%">发送时间</td>
					
					<td width="20%"><div align="center">操作</div></td>
					
                  </tr>';
			
				 // $result=$oa->query($result);
				   while($row=mysql_fetch_array($result))
	 		     {
				  
                  
				  echo '<tr bgcolor="#FFFFFF">';
				  echo' <td height="20">';
				  $get_id= $row['message_id'];
				  echo '<input type="checkbox" name="delid[]" value='.$get_id.'></td>';
                  echo '<td >'. $row['message_title'].'</td>';
				  echo '<td >'.$row['receiver'].'</td>';  
                  echo '<td>';
                  echo date("Y-m-d H:i:s",$row['send_time']);
                  echo '</td>';
                
                 
	
                   echo '<td align="center"><a href="sendxiaoximingxi.php?id='.$get_id.'">查看</a>&nbsp;| &nbsp;<a href="delete_message.php?id='.$get_id.'|'.'">删除</a></td>';
                   echo '</tr>';
				  }
           echo' </table></td></tr>
        <td>'
        .$dis_page.
        '</td>
       
     
      </table>';
      echo '</form>';
	}
}
?>
<?php
//判断提交之前查询所有用户信息
	 if(empty($_POST['search'])){
     $select="select * from message  order by message_id desc {$page->limit}";
     $result=$oa->query( $select);
     list_task($result,$dis_page);
     
}
//提交之后查询相关信息
    if(isset($_POST['search']))
	{
		$t1 = trim(($_POST['start_time']));//开始时间取出
	    $t2  = trim($_POST['stop_time']);//结束时间取出
// 	    echo $t1;exit;
	    check_date($t1);
	    check_date($t2);
	    $start_time=intval(strtotime ($t1));
	    $stop_time=intval(strtotime($t2));
	    if ($start_time>=$stop_time)
		    {
		    	echo "<script>alert('起始与终止的时间选择不正确');</script>";
		    }
		 else
			 {
				 $key_sql="select * from message where send_time>=". $start_time." and send_time<=".$stop_time." order by  message_id desc  {$page->limit}";
		 
	 			 $result_key=$oa->query($key_sql);
	 			 list_task($result_key,$dis_page);
			 }
	  }
	?>
</body>
</html>
